﻿#region Creditos

/* Autor: Edilberto Sánchez Forero	*/
/* Email: esanchezfo@gmail.com		*/
/* Licencia: LGPL, Software Libre	*/
/* País: Colombia, Bogotá			*/

#endregion

#region Librerias

using System;
using System.ServiceModel.Dispatcher;
using System.ServiceModel.Channels;
using System.ServiceModel;
using ESF.General;

#endregion


namespace ESF.WCF
{
	public sealed class WCFExceptionHandler : IErrorHandler
	{
		#region IErrorHandler Members

		public bool HandleError(Exception pEx)
		{
			Log.Error (pEx, false);
			
			// Returning true indicates you performed your behavior.
			return true;
		}


		public void ProvideFault (Exception pEx, MessageVersion pVersion, ref Message pMsg)
		{
			GenericException gEx;
			
			
			gEx = new GenericException (pEx);
			 
			pMsg = Message.CreateMessage (pVersion, new FaultCode (gEx.Code), gEx.Message, string.Empty);
		}

		#endregion
	}
}